package 并发编程08.原子操作类;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author idea
 * @data 2019/1/23
 */
public class AtomicDemo1 implements Runnable{

    private static AtomicInteger i=new AtomicInteger(0);

    private static AtomicBoolean ab=new AtomicBoolean(true);

    public void incr(){
        i.incrementAndGet();
    }

    public static void main(String[] args) {
        i.incrementAndGet();
        List<Thread> threadList=new ArrayList<>();
        for(int i=0;i<100;i++){
            Thread thread=new Thread(new AtomicDemo1());
            threadList.add(thread);
        }
        for (Thread thread : threadList) {
            thread.start();
        }


    }

    @Override
    public void run() {
        incr();
        if(i.get()==100){
            System.out.println("true");
        }
    }


}
